Index: rtp.c =================================================================== RCS file: /usr/cvsroot/asterisk/rtp.c,v retrieving revision 1.85 diff -u -r1.85 rtp.c --- rtp.c 26 Aug 2004 04:56:26 -0000 1.85 +++ rtp.c 2 Sep 2004 23:44:31 -0000 @@ -52,6 +52,9 @@ static int rtpstart = 0; static int rtpend = 0; + +static int answercodecsall = 1; + #ifdef SO_NO_CHECK static int checksums = 1; #endif @@ -730,14 +733,20 @@ } } + /* Only offer from our own list of codecs if we aren't answering-- + this prevents us from answering with codecs that have not been offered. + This behavior can be configured from rtp.conf with rtpanswercodecs set + to all or offered. */ + if (answercodecsall || rtp->rtp_offered_from_local) { /* Then the static list */ - for (pt = 0; pt < MAX_RTP_PT; ++pt) { - if (static_RTP_PT[pt].code == code && + for (pt = 0; pt < MAX_RTP_PT; ++pt) { + if (static_RTP_PT[pt].code == code && static_RTP_PT[pt].isAstFormat == isAstFormat) { - rtp->rtp_lookup_code_cache_isAstFormat = isAstFormat; - rtp->rtp_lookup_code_cache_code = code; - rtp->rtp_lookup_code_cache_result = pt; - return pt; + rtp->rtp_lookup_code_cache_isAstFormat = isAstFormat; + rtp->rtp_lookup_code_cache_code = code; + rtp->rtp_lookup_code_cache_result = pt; + return pt; + } } } return -1; @@ -1512,6 +1521,14 @@ rtpend = 1024; if (rtpend > 65535) rtpend = 65535; + } + if ((s = ast_variable_retrieve(cfg, "general", "rtpanswercodecs"))) { + if (!strcasecmp(s, "all")) { + answercodecsall = 1; + } else if (!strcasecmp(s, "offered")) { + answercodecsall = 0; + } else + ast_log(LOG_WARNING, "Invalid value for rtpanswer codecs: %s\n", s); } if ((s = ast_variable_retrieve(cfg, "general", "rtpchecksums"))) { #ifdef SO_NO_CHECK Index: configs/rtp.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/rtp.conf.sample,v retrieving revision 1.2 diff -u -r1.2 rtp.conf.sample --- configs/rtp.conf.sample 17 Jul 2004 21:08:12 -0000 1.2 +++ configs/rtp.conf.sample 2 Sep 2004 23:44:31 -0000 @@ -11,3 +11,8 @@ ; Whether to enable or disable UDP checksums on RTP traffic ; ;rtpchecksums=no +; +; Which codecs do we respond to offers with, all, or only those offered +; valid values: all (default), offered +; +;rtpanswercodecs=all